#include <stdio.h>
#include <syslog.h>

int main(){
    //打开与syslog的连接，并设置为“my_program”,使用默认选项和设施类型
    openlog("my_program",LOG_PID | LOG_CONS,LOG_USER);

    //发送不同级别的日志消息
    syslog(LOG_INFO,"This is an informational message.");
    syslog(LOG_WARNING,"This is a warning message");
    syslog(LOG_ERR,"This is an error message.");

    //关闭与syslog的连接
    closelog();
    return 0;
}